﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_StaffPages_viewDesign : System.Web.UI.Page
{
    int cId = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        cId = Convert.ToInt32(Request.QueryString["cId"].ToString());
        ManagerBUS manager = new ManagerBUS();
        Competition c = manager.searchCompetitionById(cId);
        lblName.Text = c.Name;
        lblFirstPrize.Text = c.FirstPrize;
        lblSecondPrize.Text = c.SecondPrize;
        lblThirdPrize.Text = c.ThirdPrize;
        lblStartDate.Text = c.StartDate;
        lblEndDate.Text = c.EndDate;
        lblDescription.Text = c.Description;
        lblQuotation.Text = c.Quotation;
        getAllDesignOnCompetition();
    }
    protected void btnDisplayAllCompetition_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, GetType(), "StaffViewDesign", "displayBlock('StaffViewDesign');", true);
        getAllDesignOnCompetition();
    }

    private void getAllDesignOnCompetition()
    {
        StaffBUS staff = new StaffBUS();
        Competition c = new Competition();
        c.ComId = cId;
        DataSet ds = staff.getAllDesignOnCompetition(c);
        if (ds == null)
        {
            Response.Write("<script>alert('No Competition')</script>");
        }
        else
        {
            grvMarkDesign.DataSource = ds.Tables[0];
            grvMarkDesign.DataBind();
        }
    }
    protected void grvMarkDesign_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#ceedfc'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''");
            e.Row.Attributes.Add("style", "cursor:pointer;");
            e.Row.Attributes.Add("onclick", "location='markDesign.aspx?dId=" + e.Row.Cells[0].Text + "'");
        }
    }
    protected void grvMarkDesign_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grvMarkDesign.PageIndex = e.NewPageIndex;
        getAllDesignOnCompetition();
    }
}